import axios from 'poros/http';

// const BASE_API = 'http://10.110.100.171:8030';
const BASE_API = '';

// 国家
export const getCoutryList = () =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/customer/getCoutry`,
    method: 'get',
  });
// 省、城市、区
export const getProvincesList = () =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/customer/getProvincesAndCities`,
    method: 'get',
  });
// 保存前获取id
export const postIdOrUpdate = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/process/saveOrUpdate`,
    method: 'post',
    data,
  });

// 保存
export const postSaveCustomerCreate = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/customer/launchCustomerCreate`,
    // url: 'http://10.110.100.171:8030/api/salesforecast-service/customer/launchCustomerCreate',
    method: 'post',
    data,
  });
// 校验客户名称、客户简称是否重名
export const postInspectionRepeat = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/customer/inspectionRepeat`,
    method: 'post',
    data,
  });
// 潜客列表接口
export const customerListByPage = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/customer/customerListByPage`,
    method: 'post',
    data,
  });
// tabs上传附件
export const postUploadFile = (type, id, file) => {
  const formData = new FormData();
  formData.append('file', file);
  return axios({
    url: `${BASE_API}/api/salesforecast-service/customer/upload/${type}/${id}`,
    headers: { 'Content-Type': 'multipart/form-data' },
    method: 'post',
    data: formData,
  });
};
//基本信息中删除附件
export const getDeleteFile = id =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/customer/delete/${id}`,
    method: 'get',
  });

// 基本信息详情接口
export const getQueryDetail = params =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/customer/queryDetail`,
    method: 'get',
    params
  });

// 业务线列表
export const postProfessionListByPage = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/customer/professionList`,
  // url: 'http://10.110.100.171:8030/api/salesforecast-service/customer/professionList',
  method: 'post',
  data,
});

// 新增、修改业务线
export const postProfessionInsert = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/customer/professionInsert`,
  method: 'post',
  data,
});

// 删除业务线列表
export const postProfessionDelete = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/customer/professionDelete`,
  method: 'post',
  data,
});

// 附件列表
export const postFJListByPage = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/attachment/list`,
  method: 'post',
  data,
});

// tabs附件删除
export const postFJdelete = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/customer/attachmentDeleteByIds`,
  method: 'post',
  data,
});

// 地址列表
export const postAddressListByPage = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/customer/addressListByPage`,
  method: 'post',
  data,
});

// 新增地址
export const postAddressInsert = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/customer/addressInsert`,
  method: 'post',
  data,
});

// 删除地址
export const postAddressDelete = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/customer/addressDelete`,
  method: 'post',
  data,
});

// 潜客创建法人列表
export const postLegalListByPage = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/legal/listByPage`,
  method: 'post',
  data,
});

// 潜客创建联系人列表
export const postContactsListByPage = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/contact/listByPage`,
  // url: 'http://10.110.100.171:8030/api/salesforecast-service/contact/listByPage',
  method: 'post',
  data,
});

// 潜客创建新增、修改联系人
export const postContactInsertData = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/customer/contactInsert`,
  // url: 'http://10.110.100.171:8030/api/salesforecast-service/customer/contactInsert',
  method: 'post',
  data,
});

// 潜客创建新增、修改联系人冻结、解冻接口
export const postContactUpdate = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/contact/update`,
  // url: 'http://10.110.100.171:8030/api/salesforecast-service/customer/contactInsert',
  method: 'post',
  data,
});

// 潜客创建联系人民族列表
export const getNationalList = () =>
axios({
  url: `${BASE_API}/api/salesforecast-service/customer/getNational`,
  method: 'get'
});

// 潜客创建联系人详情接口
export const getContactsDetail = (id) =>
axios({
  url: `${BASE_API}/api/salesforecast-service/contact/query/${id}`,
  method: 'get'
});

// 潜客创建批量删除联系人
export const postContactDelete = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/customer/contactDelete`,
  method: 'post',
  data,
});

// 潜客创建批量删除家庭成员
export const postContactFamilyDelete = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/family/delete`,
  method: 'post',
  data,
});

// 潜客创建发起人部门主管
export const postDepcMgrInfo = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/common/getDepcMgrInfo`,
  method: 'post',
  data,
});

// 潜客创建详情页撤回
export const postRecallInfo = id =>
axios({
  url: `${BASE_API}/api/salesforecast-service/customer/recall/${id}`,
  method: 'get',
});

// 潜客创建审批接口
export const postCustomerCreateApprove = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/customer/customerCreateApprove`,
  method: 'post',
  data,
});

// 潜客创建转他人处理接口
export const postCustomerForward = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/customer/forward`,
  method: 'post',
  data,
});

// 潜客创建批量删除接口
export const postCustomerDelete = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/customer/delete`,
  method: 'post',
  data,
});


/***8* 法人信息接口 *****/


// 法人列表接口
export const postLegalByPage = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/legal/listByPage`,
  // url: 'http://10.110.100.171:8030/api/salesforecast-service/legal/listByPage',
  method: 'post',
  data,
});

// 法人新增保存接口
export const postInsertOrUpdate = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/legal/insertOrUpdate`,
  method: 'post',
  data,
});

// 法人客户列表弹窗接口
export const postInserCustomerListByPage = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/legal/customerListByPage`,
  method: 'post',
  data,
});

// 法人详情接口
export const postInsertQueryDetail = id =>
axios({
  url: `${BASE_API}/api/salesforecast-service/legal/query/${id}`,
  method: 'get',
});

// 法人客户列表导出接口
export const postInserExport = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/legal/export`,
  method: 'post',
  responseType: 'arraybuffer',
  hasInterceptors: true,
  data,
});

// 法人客户列表导入模板下载接口
export const postDownExcelImportTemplate = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/legal/downExcelImportTemplate`,
  method: 'post',
  responseType: 'arraybuffer',
  hasInterceptors: true,
  data,
});

// 法人客户列表批量导入接口
export const postImportExcel = file => {
  const formData = new FormData();
  formData.append('file', file);
  return axios({
    url: `${BASE_API}/api/salesforecast-service/legal/importExcel`,
    headers: { 'Content-Type': 'multipart/form-data' },
    method: 'post',
    data: formData,
  });
};

// 法人客户列表删除接口
export const postLegalDelete = data =>
axios({
  url: `${BASE_API}/api/salesforecast-service/legal/delete`,
  method: 'post',
  data,
});
